package com.leyou.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version V1.0
 * @author: Ljxpa
 * @date: 2020/03/06 11:52
 * @description: 声明
 */
@Configuration
// @EnableConfigurationProperties(OSSProperties.class);如果使用这各注解，OSSProperties中的@Component注解可以不使用
public class OSSConfig {

	@Bean//这里方法需要的参数会从spring容器中获取，然后注入进来
	public OSS createClient(OSSProperties prop){
		return new OSSClientBuilder()
				.build(prop.getEndpoint(), prop.getAccessKeyId(), prop.getAccessKeySecret());
	}

}
